//主要添加表单的验证规则
var StudentInfoDialog = {

    setupFormValidation: function () {
        this.studentFormValidator = $("#form_student_info").validate({
            rules: {
                'studentNumber:string': {
                    required: true,
                    maxlength: 10,
                    pattern: '[A-Za-z0-9]+'
                },
                'name:string': {
                    required: true,
                    maxlength: 50
                },
                'idNumber:string': {
                    required: true,
                    pattern: '\\d{17}[\\d|X]|\\d{15}'
                },
                'birthDate:string': {
                    required: false,
                    pattern: '\\d{4}-\\d{2}-\\d{2}'
                },
                'phone:string': {
                    required: false,
                    pattern: '(13|14|15|17|18|19)[0-9]{9}'
                }
            },
            messages: {
                'studentNumber:string': {
                    required: '必填',
                    maxlength: '学号最多 10 个字符',
                    pattern: '[A-Za-z0-9]+'
                },
                'name:string': {
                    required: '必填',
                    maxlength: '名字最多 50 个字符'
                },
                'idNumber:string': {
                    required: '必填',
                    pattern: '请输入正确的身份证，最后一位为数字或大写字母 X'
                },
                'birthDate:string': {
                    pattern: '请输入正确的日期，例如: 1990-01-01'
                },
                'phone:string': {
                    pattern: '请输入正确的国内手机号'
                }
            }
        });
    },
    resetAccountInfoDialog: function () {
        this.studentFormValidator.resetForm();
        $('input.uk-form-danger').removeClass('uk-form-danger');
    },
    addSaveButtonClickHandler: function (handler) {
        $('#btn_save_account').click(handler);
    }
};